package org.kfive.nova.hadoop.mapper;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.StringTokenizer;

/*
* WordCountMapper.java
* Created  by  dell
* Created on 2016/3/29 17:53
*/
public class WordCountMapper extends Mapper<LongWritable,Text,Text,IntWritable> {

    public void map(LongWritable key,Text value,Context context) throws IOException,InterruptedException{

        StringTokenizer iterator = new StringTokenizer(value.toString());
        while (iterator.hasMoreElements()){
            context.write(new Text(iterator.nextToken()),new IntWritable(1));
        }

    }

}
